public class Main {
    public static void main(String[] args) {
        Shape[] shapes = {
                new Circle(5.00),
                new Rectangle(4, 6),
                new Triangle(3, 4, 5)
        };
 /*       (Shape shape : shapes) AI查询
        public class ForEachExample {
            public static void main(String[] args) {
                // 定义一个水果数组
                String[] fruits = {"苹果", "香蕉", "橙子"};

                // 使用增强 for 循环遍历数组
                for (String fruit : fruits) {
                    System.out.println("我拿到了一个 " + fruit);
                }
            }
        }
        我拿到了一个 苹果
        我拿到了一个 香蕉
        我拿到了一个 橙子
*/
        for (Shape shape : shapes) {
            if (shape instanceof Circle) {
                System.out.println("圆形：");
                // 保留三位小数输出圆形的面积和周长
                System.out.printf("面积：%.3f\n", shape.calcArea());
                System.out.printf("周长：%.3f\n", shape.calcPerimeter());
            } else if (shape instanceof Rectangle) {
                System.out.println("矩形：");
                System.out.println("面积：" + shape.calcArea());
                System.out.println("周长：" + shape.calcPerimeter());
            } else if (shape instanceof Triangle) {
                System.out.println("三角形：");
                System.out.println("面积：" + shape.calcArea());
                System.out.println("周长：" + shape.calcPerimeter());
            }
            System.out.println();
        }
    }
}